package com.tzxx.spider.service;

import lombok.extern.slf4j.Slf4j;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.tzxx.spider.dao.TemplateMapper;
import com.tzxx.spider.domain.Template;
import com.tzxx.spider.vo.PageVo;
import com.github.pagehelper.PageHelper;

/**
 * @author Created by tzxx
 * @since : 2019/7/22.
 */
@Slf4j
@Service
@Transactional
public class TemplateService {
    @Resource
    private TemplateMapper templateMapper;

    public void insert(Template template) {
        templateMapper.insert(template);
    }

    public List<Template> getAllTemplate(PageVo pageVo) {
        PageHelper.startPage(pageVo.getPageNumber(), pageVo.getPageSize());
        return templateMapper.select(pageVo);
    }

    public Template getTemplateById(long id) {
        return templateMapper.selectById(id);
    }
}
